package cn.bugstack.springframework.beans;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * <p>属性值集合
 *
 * @author Yaxi.Zhang
 * @since 2022/12/13 00:25
 */
public class PropertyValues {

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(PropertyValue pv) {
        this.propertyValueList.add(pv);
    }

    public PropertyValue[] getPropertyValues() {
        return propertyValueList.toArray(new PropertyValue[0]);
    }

    public PropertyValue getPropertyValue(String propertyName) {
        return propertyValueList.stream().filter(it -> Objects.equals(it.getName(), propertyName)).findFirst().orElse(null);
    }

}
